<?php
	/* Requires the Zend Framework v1.5.3 and PHP v5.1.4 or higher */

	// PHP version check
	if (version_compare("5.1.4", PHP_VERSION) > 0)
		die("PHP v5.1.4 or better is required.");

	set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/libs');
	require_once 'Zend/Db.php';
	require_once 'Zend/Log.php';
	require_once 'Zend/Log/Writer/Null.php';
	//require_once 'Zend/Log/Writer/Stream.php';  // Uncomment this line to write output to a file

	// Setup our Zend logger
	if (class_exists('Zend_Log_Writer_Stream'))
		$writer = new Zend_Log_Writer_Stream('gcms.log');
	else
		$writer = new Zend_Log_Writer_Null;
	$logger = new Zend_Log($writer);
	//$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN));

	try {
		$db = Zend_Db::factory('Mysqli', array(
			'host'     => 'localhost',
			'username' => 'gcms',
			'password' => 'gcms',
			'dbname'   => 'gcms',
			'options'  => array()
		));
		$db->getConnection();
	} catch (Zend_Db_Adapter_Exception $e) {
		$logger->log('DB connection error: ' . $e->getMessage(), Zend_Log::ERR);
		// mail("webmaster@domain.com", "Database Error", "Connection error, check logs.");
		die($e->getMessage());
	}
	$db->query("SET NAMES 'utf8'") or die("Cannot set utf-8"); // Set UTF-8 mode for older ZF
?>
